package com.kaola.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.kaola.dao.AdminDAO;
import com.kaola.pojo.Admin;

public class AdminDAOImpl extends HibernateTemplate implements AdminDAO {

	private Admin admin = null;
	private List<Admin> admins;
	
	public void add(Admin admin) {
		save(admin);
	}

	public Admin get(int id) {
		return get(Admin.class, id);
	}

	public Admin get(String account) {
		admins = find("from Admin a where a.account=?", account);
		if (admins.size() > 0) {
			admin = admins.get(0);
		}
		return admin;
	}
	
	public void delete(int id) {
		delete(get(id));
	}
}
